#ifndef CTRLREPORT_H
#define CTRLREPORT_H

#include <QObject>
#include <QString>
#include <QDebug>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QNetworkRequest>
#include <QXmlStreamWriter>
#include <QCryptographicHash>
#include <QFile>
#include <QDir>
#include <QTimer>
#include <QApplication>
#include <QStringList>
#include "ctrlinfo.h"
#include "reporttask.h"

class CtrlReport : public QObject
{
    Q_OBJECT
public:
    explicit CtrlReport(QObject *parent = 0);
    void setServerAddress(QString addr);

private:
    QString address;
    ctrlInfo* curInfo;
    QString curReport;
    QStringList fileList;
    QTimer* taskTimer;
    QDir reportDir;
    int repFlag;
    QNetworkAccessManager* manager;
    QNetworkReply* reportReply;

    QString xmlReport(ctrlInfo* info);
    QString utf8ToUnicode(QString utf);
    void sendReport(QString reportFile);

signals:
    void reportRst(bool);

public slots:
    void newReport(ctrlInfo* info);

private slots:
    void recv_goods_report();
    void taskclearTimeout();//clear local tasks
    void nextTaskTimeout();
};

#endif // CTRLREPORT_H
